#include <iostream>
#include <unistd.h>
#include <ctype.h>
#include <cstdlib>

using namespace std;

#include "Option.h"

int main(int argc, char **argv)
{
    int c;
    int n = NULL;
    double strike = NULL;
    string filename = "setting.csv";

    opterr = 0;

    while ((c = getopt(argc, argv, "n:k:f:")) != -1) {
        switch(c) {
            case 'n':
                n = atoi(optarg);
                break;
            case 'k':
                strike = atof(optarg);
                break;
            case 'f':
                filename = optarg;
                break;
            case '?':
				if (optopt == 'n' || optopt == 'k' || optopt == 'f') {
					cerr << "Option -" << optopt << " requires an argument." << endl;
				} else if (isprint(optopt)) {
					cerr << "Unknown `-" << optopt << "`." << endl;
				} else {
					cerr << "Unknown character `" << optopt << "`." << endl;
				}
                return 1;
            default:
                abort();
        }
    }

    //Random *r = new NormRand();
    //for (int i = 0; i < 1000; i++) 
    //cout << "normal random number is " << r->rand() << endl;

    Option *call = new CallOption();
    call->setTrialNumber(n);
    call->setStrike(strike);
    cout << *call << endl;
    //cout << "call price is " << call->getPrice() << endl;

    Option *call1 = new CallOption(filename);
    //call1->setTrialNumber(n);
    cout << *call1 << endl;

    Option *put = new PutOption();
    cout << *put << endl;
    return 0;
}
